package com.dailywork.basepro.thread.executors;

import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.TimeUnit;

/**
 * ForkJoin多线程框架
 *
 * @author think
 * @version 1.0.0
 * @since 2020/1/14
 */
public class ForkJoinPoolAction {
    public static void main(String[] args) throws Exception {
        PrintTask task = new PrintTask(0, 5);
        // 创建实例，并执行分割任务
        ForkJoinPool pool = new ForkJoinPool();
        pool.submit(task);
        // 线程阻塞，等待所有任务完成
        pool.awaitTermination(2, TimeUnit.SECONDS);
        pool.shutdown();
    }
}
